﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

using DuelQuizzServer;

namespace DuelQuizz
{
    /// <summary>
    /// Logique d'interaction pour Question.xaml
    /// </summary>
    public partial class QuestionControl : UserControl
    {
        Question question;
        Answer selectedAnswer;

        public Answer SelectedAnswer {
            get { return this.selectedAnswer; }
        }

        public QuestionControl() : base()
        {
            question = new Question();
            InitializeComponent();
        }

        public QuestionControl(Question question) : this()
        {
            this.question = question;
        }

        public void SetQuestion(Question question) {
            this.question = question;

            title.Content = question.title;
            title.IsEnabled = false;
            text.Content = question.text;
            text.IsEnabled = false;
            answer0.Content = question.answers.ElementAt(0).text;
            answer1.Content = question.answers.ElementAt(1).text;
            answer2.Content = question.answers.ElementAt(2).text;
            answer3.Content = question.answers.ElementAt(3).text;
        }

        private void answer0_Click(object sender, RoutedEventArgs e)
        {
            selectedAnswer = question.answers.ElementAt(0);
        }

        private void answer1_Click(object sender, RoutedEventArgs e)
        {
            selectedAnswer = question.answers.ElementAt(1);
        }

        private void answer2_Click(object sender, RoutedEventArgs e)
        {
            selectedAnswer = question.answers.ElementAt(2);
        }

        private void answer3_Click(object sender, RoutedEventArgs e)
        {
            selectedAnswer = question.answers.ElementAt(3);
        }
    }
}